import os.path as osp

import subprocess

import sys

from collections import defaultdict



import cv2

import torch

import torchvision





def collect_env():

    env_info = {}

    env_info['sys.platform'] = sys.platform

    env_info['Python'] = sys.version.replace('\n', '')



    cuda_available = torch.cuda.is_available()

    env_info['CUDA available'] = cuda_available



    gcc = subprocess.check_output('gcc --version | head -n1', shell=True)

    gcc = gcc.decode('utf-8').strip()

    env_info['GCC'] = gcc



    env_info['PyTorch'] = torch.__version__
    
    env_info['torch.cuda'] = torch.version.cuda


    env_info['TorchVision'] = torchvision.__version__



    env_info['OpenCV'] = cv2.__version__

    return env_info





if __name__ == '__main__':

    for name, val in collect_env().items():

        print(f'{name}: {val}')